/* =============================================
   COMPANY PROFILE PAGE
   ============================================= */

/* Company Hero — uses shared .page-hero from style.css */
/* Override: full-width content (company layout needs full row) */
.page-hero .page-hero-content {
  max-width: none;
}
/* Slightly tighter bottom padding */
.page-hero.cp-hero {
  padding-bottom: 48px;
}

.cp-company-header {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.cp-company-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-color);
  flex-shrink: 0;
  overflow: hidden;
}

.cp-company-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.cp-company-info {
  flex: 1;
}

.cp-company-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.cp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(var(--secondary-rgb),0.15);
  border: 1px solid rgba(var(--secondary-rgb),0.3);
  border-radius: 100px;
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-color);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.cp-badge.cp-badge-sector {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
}

.cp-company-name {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  line-height: 1.2;
}

.cp-company-meta {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 0.88rem;
  color: rgba(255,255,255,0.6);
  flex-wrap: wrap;
}

.cp-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cp-meta-item svg {
  display: block;
  width: 16px;
  height: 16px;
  opacity: 0.6;
  flex-shrink: 0;
}

.cp-meta-label {
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Quick Stats — uses shared .page-hero-stats / .page-hero-stat from style.css */

/* Tab Navigation - reusing rr-tabs pattern */
/* Tab Navigation → dùng shared .tabs-nav / .tabs-list / .tab-btn / .tab-content trong style.css */

/* Section Layout */
.cp-section {
  padding: 48px 0;
}

.cp-section + .cp-section {
  border-top: 1px solid var(--border-color);
}

.cp-section-header {
  margin-bottom: 28px;
}

.cp-section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--secondary-color);
  margin-bottom: 8px;
}

.cp-section-label svg {
  width: 16px;
  height: 16px;
}

.cp-section-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--primary-color);
  margin-bottom: 8px;
  line-height: 1.2;
}

.cp-section-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 640px;
}

/* Overview Tab - Block 1: Company Intro */
.cp-intro-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
}

.cp-intro-text {
  font-size: 0.95rem;
  color: var(--text-dark);
  line-height: 1.8;
}

.cp-intro-text p {
  margin-bottom: 16px;
}

.cp-info-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
}

.cp-info-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.cp-info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
}

.cp-info-row:last-child {
  border-bottom: none;
}

.cp-info-label {
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
  margin-right: 16px;
}

.cp-info-value {
  color: var(--text-dark);
  font-weight: 600;
  text-align: right;
}

/* Block 2: Credit Opinion */
.cp-opinion-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.cp-opinion-summary {
  font-size: 0.95rem;
  color: var(--text-dark);
  line-height: 1.8;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.cp-opinion-factors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.cp-factor-card {
  padding: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.cp-factor-card.upgrade {
  background: rgba(16,185,129,0.04);
  border-color: rgba(16,185,129,0.15);
}

.cp-factor-card.downgrade {
  background: rgba(239,68,68,0.04);
  border-color: rgba(239,68,68,0.15);
}

.cp-factor-card.strength {
  background: rgba(var(--secondary-rgb),0.04);
  border-color: rgba(var(--secondary-rgb),0.12);
}

.cp-factor-card.challenge {
  background: rgba(245,158,11,0.04);
  border-color: rgba(245,158,11,0.12);
}

.cp-factor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.cp-factor-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cp-factor-card.upgrade .cp-factor-icon {
  background: rgba(16,185,129,0.12);
  color: #059669;
}

.cp-factor-card.downgrade .cp-factor-icon {
  background: rgba(239,68,68,0.12);
  color: #dc2626;
}

.cp-factor-card.strength .cp-factor-icon {
  background: rgba(var(--secondary-rgb),0.1);
  color: var(--secondary-color);
}

.cp-factor-card.challenge .cp-factor-icon {
  background: rgba(245,158,11,0.1);
  color: #d97706;
}

.cp-factor-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-color);
}

.cp-factor-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.cp-factor-text ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.cp-factor-text ul li {
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.cp-factor-text ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
}

.cp-opinion-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.cp-opinion-action .btn {
  font-size: 0.85rem;
}

/* Block 3: Rating Snapshot */
.cp-rating-snapshot {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}

.cp-rating-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.cp-rating-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.cp-rating-card-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.cp-rating-value {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1.2;
  margin-bottom: 8px;
}

.cp-rating-value.grade-high { color: #059669; }
.cp-rating-value.grade-mid { color: #d97706; }
.cp-rating-value.grade-low { color: #dc2626; }
.cp-rating-value.grade-wr { color: #6b7280; }

.cp-rating-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.cp-rating-detail .cp-outlook {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.cp-outlook.stable { color: #059669; }
.cp-outlook.negative { color: #dc2626; }
.cp-outlook.positive { color: #2563eb; }
.cp-outlook.wr { color: #6b7280; }

/* Block 4 & 5: Reports List */
.cp-reports-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cp-report-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.15s;
}

.cp-report-item:last-child {
  border-bottom: none;
}

.cp-report-item:hover {
  background: rgba(var(--secondary-rgb),0.02);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  border-radius: var(--radius-sm);
}

.cp-report-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(var(--secondary-rgb),0.08);
  color: var(--secondary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cp-report-info {
  flex: 1;
  min-width: 0;
}

.cp-report-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cp-report-title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.cp-report-title a:hover {
  color: var(--secondary-color);
}

.cp-report-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cp-report-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-color);
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
}

.cp-report-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.cp-view-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--secondary-color);
  text-decoration: none;
  margin-top: 16px;
  transition: gap 0.2s;
}

.cp-view-all:hover {
  gap: 10px;
}

/* =============================================
   TAB 2: RATING RESULTS
   ============================================= */


/* Rating Overview - Tab 2.1 */
.cp-rating-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.cp-ro-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.cp-ro-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.cp-ro-big-rating {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
}

.cp-ro-card-compact .cp-ro-big-rating {
  font-size: 3.2rem;
  margin-bottom: 0;
  background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cp-ro-big-rating.grade-high { color: #059669; }
.cp-ro-big-rating.grade-mid { color: #d97706; }
.cp-ro-big-rating.grade-low { color: #dc2626; }
.cp-ro-big-rating.grade-wr { color: #6b7280; }

.cp-ro-outlook-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.cp-ro-outlook-label {
  color: var(--text-muted);
}

/* Deco panel — lotus animation */
.cp-ro-card-deco {
  position: relative;
  flex: 1;
  overflow: hidden;
  z-index: 2;
  min-height: 140px;
}

.cp-ro-lotus {
  position: absolute;
  pointer-events: none;
  user-select: none;
  background-color: var(--secondary-color);
  mask-image: url('/assets/imglotus.svg');
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: url('/assets/img/lotus.svg');
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  opacity: 0.25;
}

.cp-ro-lotus-1 {
  width: 340px;
  height: 340px;
  right: -80px;
  top: 50%;
  transform: translateY(-50%);
}

.cp-ro-card-compact {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  margin-bottom: 24px;
  background: linear-gradient(135deg,
    rgba(var(--secondary-rgb), 0.10) 0%,
    rgba(var(--secondary-rgb), 0.05) 50%,
    rgba(var(--accent-rgb), 0.07) 100%);
  border: 1px solid rgba(var(--secondary-rgb), 0.18);
  box-shadow: 0 4px 24px rgba(var(--secondary-rgb), 0.07);
  overflow: hidden;
  position: relative;
}

/* Shimmer layer — same as stats-inner-box */
.cp-ro-card-compact::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg,
    transparent 20%,
    rgba(var(--secondary-rgb), 0.06) 50%,
    transparent 80%);
  background-size: 200% 100%;
  animation: stats-shimmer 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

.cp-ro-card-info {
  position: relative;
  z-index: 2;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}

.cp-ro-card-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 0;
}

.cp-list-subtitle {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 12px;
}

/* Timeline */
.cp-timeline {
  position: relative;
  padding: 24px 0;
}

.cp-timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 24px;
  width: 2px;
  background: var(--border-color);
}

.cp-timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 0;
  position: relative;
}

.cp-timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--secondary-color);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--secondary-color);
  flex-shrink: 0;
  margin-top: 4px;
  margin-left: 19px;
  position: relative;
  z-index: 1;
}

.cp-timeline-dot.current {
  background: #059669;
  box-shadow: 0 0 0 2px #059669;
}

.cp-timeline-info {
  flex: 1;
}

.cp-timeline-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.cp-timeline-rating {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-color);
}

.cp-timeline-action {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Rating Table - Tab 2.2 & 2.3 */
.cp-rating-table {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: visible;
  box-shadow: var(--shadow-sm);
}

.cp-rt-head {
  position: relative;
  display: grid;
  padding: 12px 24px;
  background: var(--primary-color);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cp-rt-head span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Ensure filter header has high z-index for popover */
.cp-rt-head.rr-header-relative {
  z-index: 10001 !important;
}

.cp-rt-col-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 3px;
  padding: 2px 4px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  flex-shrink: 0;
  line-height: 1;
  font-size: 0;
}

.cp-rt-col-filter:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--primary-color);
  border-color: rgba(0, 0, 0, 0.3);
}

.cp-rt-col-filter.is-selected {
  background: rgba(var(--secondary-rgb), 0.1);
  color: var(--secondary-color);
  border-color: rgba(var(--secondary-rgb), 0.35);
}

.cp-rt-col-filter svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
  stroke: none;
  display: block;
}

.cp-rh-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-width: 340px;
}

.cp-rh-table-wrap .cp-rating-table {
  min-width: 0;
}

.cp-rh-table-section[data-type="issuer"] .cp-rating-table {
  min-width: 0;
}

.cp-rh-table-section[data-type="debt"] .cp-rating-table {
  /* Desktop: set min-width to enable horizontal scroll
     90+200+90+110+80+140+100+130+90+100+90 = 1220px + 10×12px gap = 1340px */
  min-width: 1340px;
}

.cp-rt-head-issuer {
  grid-template-columns: 120px 1fr 130px 130px 80px;
  gap: 16px;
}

/* Desktop: 11 columns, 1fr cho "Trái phiếu" để co giãn theo container.
   Tổng cố định: ~980px + 10×12px gap = 1100px */
.cp-rt-head-debt {
  grid-template-columns: 90px 1fr 90px 110px 80px 140px 100px 130px 90px 100px 90px;
  gap: 12px;
}

.cp-rt-row {
  display: grid;
  padding: 14px 24px;
  font-size: 0.88rem;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
  align-items: center;
}

.cp-rt-row:hover {
  background: rgba(var(--secondary-rgb),0.03);
}

.cp-rt-row-issuer {
  grid-template-columns: 120px 1fr 130px 130px 80px;
  gap: 16px;
}

.cp-rt-row-debt {
  grid-template-columns: 90px 1fr 90px 110px 80px 140px 100px 130px 90px 100px 90px;
  gap: 12px;
}

.cp-rt-cell {
  color: var(--text-dark);
}

.cp-rt-cell.muted {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.cp-rt-cell.entity-name {
  font-weight: 600;
  color: var(--primary-color);
}
/*The last 3 lines have been updated. */
.cp-rt-row-debt .rr-outlook {
  width: 72px;
  padding: 2px 6px;
  word-wrap: break-word; 
  overflow-wrap: break-word; 
  hyphens: auto;
}

/*New*/
.cp-rt-cell.text-left {
  text-align: left;
  justify-self: start;
}

.cp-rt-cell.text-right {
  text-align: right;
  justify-self: end;
}

.cp-rt-cell.text-center {
  text-align: center;
  justify-self: center;
}

.cp-rt-cell-report {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.cp-rt-cell-report .rr-report-link {
  display: inline;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--secondary-color);
  text-decoration: none;
}

.cp-rt-cell-report .rr-report-link:hover {
  text-decoration: underline;
}

.cp-rt-cell-report .cp-rt-report-sep {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* =============================================
   TAB 3: SPO
   ============================================= */

.cp-spo-table-wrapper {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  max-height: 600px;
  display: flex;
  flex-direction: column;
}

.cp-spo-table {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.cp-spo-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-color);
}

.cp-spo-result-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.rr-result-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 12px;
}

.cp-spo-head {
  display: grid;
  grid-template-columns: 110px 1fr 160px 1fr 140px;
  min-width: 900px;
  padding: 12px 24px;
  background: var(--primary-color);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.cp-spo-head.rr-header-relative {
  position: sticky;
  z-index: 10001 !important;
}

.cp-spo-head span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cp-spo-col-filter {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  padding: 4px;
}

.cp-spo-col-filter svg {
  width: 13px;
  height: 13px;
}

.cp-spo-col-filter:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.cp-spo-col-filter.is-selected {
  background: rgba(255, 255, 255, 0.26);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

.cp-spo-row {
  display: grid;
  grid-template-columns: 110px 1fr 160px 1fr 140px;
  min-width: 900px;
  padding: 14px 24px;
  font-size: 0.88rem;
  border-bottom: 1px solid #f1f5f9;
  gap: 16px;
  align-items: center;
  transition: background 0.15s;
}

.cp-spo-row:hover {
  background: rgba(var(--secondary-rgb),0.03);
}

.cp-spo-cell {
  color: var(--text-dark);
}

.cp-spo-cell.muted {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.cp-spo-cell a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--secondary-color);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}

.cp-spo-cell a:hover {
  text-decoration: underline;
}

/* SPO Sticky Header */
.cp-spo-table-wrapper {
  position: relative;
}

.cp-spo-head.sticky,
.cp-spo-head.sticky-clone {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-top: 0;
}

.cp-spo-head.sticky-original {
  opacity: 0;
  visibility: hidden;
}

/* Scroll sync for SPO table */
.cp-spo-table {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.2) transparent;
}

.cp-spo-table::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.cp-spo-table::-webkit-scrollbar-track {
  background: transparent;
}

.cp-spo-table::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.2);
  border-radius: 4px;
}

.cp-spo-table::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0,0,0,0.3);
}

.cp-spo-table::-webkit-scrollbar-corner {
  background: transparent;
}

/* Empty State */
.cp-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

/* Allow overflow for SPO table when filter is open */
.cp-spo-table-wrapper.filter-open {
  overflow: visible !important;
  position: relative;
  z-index: 10000;
}

.cp-spo-table-wrapper.filter-open .cp-spo-head {
  z-index: 10001 !important;
}

.cp-empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 12px;
  background: var(--surface-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.cp-empty-text {
  font-size: 0.9rem;
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 992px) {
  .cp-company-name { font-size: 2rem; }
  .cp-intro-grid { grid-template-columns: 1fr; }
  .cp-opinion-factors { grid-template-columns: 1fr; }
  .cp-rating-snapshot { grid-template-columns: 1fr 1fr; }
  .cp-rating-overview { grid-template-columns: 1fr; }

  .cp-rt-head-issuer, .cp-rt-row-issuer {
    grid-template-columns: 100px minmax(200px, 1fr) 110px 110px 80px;
    gap: 12px;
  }

  .cp-spo-head,
  .cp-spo-row {
    min-width: 980px;
    grid-template-columns: 104px 280px 128px 280px 120px;
    gap: 12px;
  }
}

@media (max-width: 768px) {
  .cp-company-name { font-size: 1.6rem; }
  .cp-company-header { gap: 16px; }
  .cp-company-logo { width: 56px; height: 56px; font-size: 1.2rem; border-radius: 12px; }
  .cp-section { padding: 32px 0; }
  .cp-section-title { font-size: 1.3rem; }
  .tab-btn { padding: 12px 16px; font-size: 0.82rem; gap: 4px; }
  .tab-icon { width: 16px; height: 16px; }
  .cp-rating-snapshot { grid-template-columns: 1fr; }
  .cp-rating-value { font-size: 2rem; }

  .cp-rt-head, .cp-rt-row {
    padding: 10px 16px;
    font-size: 0.78rem;
    gap: 10px;
  }

  .cp-rt-head-issuer, .cp-rt-row-issuer {
    grid-template-columns: 100px 240px 110px 110px 80px;
    gap: 12px;
  }

  /* Mobile: columns cố định, table scroll ngang */
  .cp-rt-head-debt, .cp-rt-row-debt {
    grid-template-columns: 90px 180px 90px 110px 80px 140px 100px 130px 90px 100px 90px;
    gap: 12px;
  }

  .cp-rh-table-section[data-type="issuer"] .cp-rating-table {
    min-width: 0;
    width: max-content;
  }

  .cp-rh-table-section[data-type="debt"] .cp-rating-table {
    /* 90+180+90+110+80+140+100+130+90+100+90 = 1200px + 10×12px = 1320px */
    min-width: 1320px;
  }

  .cp-spo-head,
  .cp-spo-row {
    min-width: 940px;
    grid-template-columns: 100px 260px 120px 260px 112px;
    gap: 10px;
  }

  .cp-spo-toolbar {
    padding: 10px 16px;
  }

  .cp-spo-head,
  .cp-spo-row,
  .cp-rt-head-issuer,
  .cp-rt-row-issuer,
  .cp-rt-head-debt,
  .cp-rt-row-debt {
    white-space: nowrap;
  }

  .cp-spo-cell:nth-child(2),
  .cp-spo-cell:nth-child(4),
  .cp-rt-row-debt .cp-rt-cell:nth-child(2),
  .cp-rt-row-debt .cp-rt-cell:nth-child(8) {
    white-space: normal;
    line-height: 1.4;
  }
}

@media (max-width: 480px) {
  /* Stats: 2×2 grid on small mobile */
  .page-hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
  }

  /* Company name nhỏ hơn trên điện thoại */
  .cp-company-name { font-size: 1.25rem; }

  /* Stack buttons xếp hạng */
  .cp-opinion-action {
    flex-direction: column;
    align-items: stretch;
  }
  .cp-opinion-action .btn {
    justify-content: center;
    text-align: center;
    width: 100%;
  }

  .cp-company-meta { flex-direction: column; gap: 8px; align-items: flex-start; }
}

/* Touch landscape: enlarge lotus and prevent clipping */
@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .cp-ro-card-compact {
    overflow: visible;
  }

  .cp-ro-card-compact::before {
    z-index: 0;
  }

  .cp-ro-card-info {
    z-index: 3;
  }

  .cp-ro-card-deco {
    min-height: 180px;
    overflow: visible;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
  }

  .cp-ro-lotus-1 {
    position: relative;
    width: 320px;
    height: 320px;
    max-width: 100%;
    max-height: 100%;
    right: auto;
    top: auto;
    transform: none;
    margin-right: 0;
    mask-size: contain;
    -webkit-mask-size: contain;
  }
}

/* Stack logo + tên công ty trên màn rất nhỏ */
@media (max-width: 400px) {
  .cp-company-header {
    flex-direction: column;
    gap: 12px;
  }
}

/* Overview process nav: sticky below tabs-nav */
.cp-overview-process-nav {
  top: calc(var(--nav-height, 69px) + var(--cp-tabs-height, 50px) - 1px);
  z-index: 49;
}

/* Rating History Chart CSS → moved to style.css (shared component) */

/* Filter popup fix - prevent clipping */
.cp-rt-head {
  overflow: visible !important;
}

/* When filter is open, allow overflow on the table - higher specificity */
.cp-rh-table-section .cp-rating-table.filter-open {
  overflow: visible !important;
}

/* Maintain rounded bottom corners when overflow is visible */
.cp-rating-table.filter-open .cp-rt-row:last-child:first-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.cp-rating-table.filter-open .cp-rt-row:last-child {
  border-bottom: none;
}

/* Keep scroll in table wrapper when filter is open */
.cp-rh-table-wrap.filter-open {
  overflow-x: auto;
}

/* Allow overflow on section when filter is open */
.cp-rh-table-section.filter-open {
  overflow: visible;
  position: relative;
  z-index: 100;
}

/* Add max-height and vertical scroll for rating tables when filter is open */
.cp-rh-table-wrap.filter-open .cp-rating-table {
  max-height: 600px;
  overflow-y: auto !important;
}

.cp-rh-table-wrap .cp-rating-table {
  overflow: visible;
}

/* Filter wrapper - use fixed positioning to avoid clipping */
.cp-rh-table-section .cp-rt-filter-wrapper {
  position: fixed;
  z-index: 10000;
}

/* Filter popover - use static inside wrapper since wrapper is fixed */
.rr-filter-popover.cp-rt-filter-popover {
  position: static;
}

.cp-rt-head.sticky {
  position: fixed;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* Hide original header when sticky clone is active */
.cp-rt-head.sticky-original {
  visibility: hidden;
}

/* Sticky clone styles */
.cp-rt-head-clone {
  pointer-events: auto;
}

/* No data message for filter results */
.cp-no-data-message {
  display: block;
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
